<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">

        <ui:define name="title">
            <h2><a href="#">Caixa de Entrada</a></h2>
        </ui:define>

        <ui:define name="body">
            <h:form id="forminbox">
                <br/>
                <div class="container_24">

                    <p:commandButton id="cxe" update="@this,  :forminbox:inboxDataTable, :forminbox:env" 
                                     process="@this"
                                     actionListener="#{managerInbox.modeRecebidos()}"
                                     value="Cx. Entrada "  
                                     icon="ui-icon-transferthick-e-w"
                                     styleClass="ui-priority-primary" style="float: right; #{managerInbox.enviados ? 'Display: block;':'Display: none;'}"/>
                    
                    <p:commandButton id="env" update="@this, :forminbox:inboxDataTable, :forminbox:cxe" 
                                     process="@this"
                                     actionListener="#{managerInbox.modeEnviados()}"
                                     value="Enviados" 
                                     icon="ui-icon-transferthick-e-w"
                                     styleClass="ui-priority-primary" style="float: right; #{!managerInbox.enviados ? 'Display: block;':'Display: none;'}"/>
                    <br/>
                    <br/>

                    <p:dataTable id="inboxDataTable" var="inbox" value="#{managerInbox.messages}" 
                                 styleClass="grid_24"
                                 rowIndexVar="rowid"
                                 emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            #{managerInbox.enviados ? 'Enviados':'Cx. Entrada'}
                        </f:facet>
                        <p:column headerText="Abrir" width="75" style="text-align: center">
                            <p:commandButton  update="@form" title="Visualisar Mensagem"
                                              actionListener="#{managerInbox.readMessage(inbox)}"
                                              icon="ui-icon-mail-open" />
                        </p:column>
                        <p:column headerText="De" rendered="#{!managerInbox.enviados}"  width="200">  
                            <h:outputText value="#{inbox.userFrom.nome}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                        </p:column>  
                        <p:column headerText="Para" rendered="#{managerInbox.enviados}" width="200">  
                            <h:outputText value="#{inbox.userTo.nome}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                        </p:column>  
                        <p:column headerText="Projeto" width="200">  
                            <h:outputText value="#{inbox.projeto.nome}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                        </p:column>  
                        <p:column headerText="Assunto" width="450" style="white-space: pre-wrap;">  
                            <h:outputText value="#{inbox.subject}" styleClass="#{inbox.wasRead ? '' : 'unRead'}" />
                        </p:column>
                        <p:column headerText="Data">    
                            <h:outputText value="#{inbox.dateMessage}" styleClass="#{inbox.wasRead ? '' : 'unRead'}">
                                <f:convertDateTime pattern="dd/MM/yyyy - HH:mm" />
                            </h:outputText>
                        </p:column>  

                    </p:dataTable> 
                </div>
            </h:form>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/><br/><br/><br/><br/><br/><br/><br/>
        </ui:define>
    </ui:composition>
</html>
